﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using NasuTek.Shion.Extencibility;
using WeifenLuo.WinFormsUI.Docking;

namespace NasuTek.Shion
{
    public partial class PluginManager : DockContent
    {
        public PluginManager()
        {
            InitializeComponent();
            foreach (KeyValuePair<string, ExtencibilityManager.PluginData> i in Form1.em.Plugins)
            {
                ListViewItem item = new ListViewItem(i.Value.Name);
                item.SubItems.Add(i.Value.Copyright);
                item.SubItems.Add(i.Value.Author);
                item.SubItems.Add(i.Value.Description);
                item.SubItems.Add(i.Value.Version.ToString());
                listView1.Items.Add(item);
            }

            TreeNode assemblies = new TreeNode("Loaded Assemblies");
            foreach (Assembly i in AppDomain.CurrentDomain.GetAssemblies())
            {
                assemblies.Nodes.Add(i.FullName);
            }
            TreeNode aliases = new TreeNode("Aliases");
            foreach (KeyValuePair<string, Alias> i in Form1.em.Aliases)
            {
                aliases.Nodes.Add(i.Key);
            }
            TreeNode onCommands = new TreeNode("OnMessage");
            TreeNode onMessage = new TreeNode("OnMessage");
            foreach (KeyValuePair<string, OnCommand> i in Form1.em.OnMessage)
            {
                onMessage.Nodes.Add(i.Key);
            }
            TreeNode onAction = new TreeNode("OnAction");
            foreach (KeyValuePair<string, OnCommand> i in Form1.em.OnAction)
            {
                onAction.Nodes.Add(i.Key);
            }
            TreeNode onNotice = new TreeNode("OnNotice");
            foreach (KeyValuePair<string, OnCommand> i in Form1.em.OnMessage)
            {
                onNotice.Nodes.Add(i.Key);
            }
            TreeNode onRaw = new TreeNode("OnRaw");
            foreach (KeyValuePair<string, OnRaw> i in Form1.em.OnRaw)
            {
                onRaw.Nodes.Add(i.Key);
            }
            onCommands.Nodes.Add(onMessage);
            onCommands.Nodes.Add(onAction);
            onCommands.Nodes.Add(onNotice);
            onCommands.Nodes.Add(onRaw);

            treeView1.Nodes.Add(assemblies);
            treeView1.Nodes.Add(aliases);
            treeView1.Nodes.Add(onCommands);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void PluginManager_Load(object sender, EventArgs e)
        {

        }

        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {

        }
    }
}
